﻿
//关闭当前页 返回父页面
function closePage(isReload) {
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index); //再执行关闭
    if (isReload) {
        parent.search();
    }
}

layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = layui.layer;

    $(function () {
        if (app.getRequest('GUID')) {
            initData();
        }
        setKindEditor();
    });

    //初始化表单
    function initData() {
        var fieldData = {
            GUID: app.getRequest('GUID'),
            PostType: "get",
            ActionType: "Notice"
        };
        app.loadData("Notice.ashx", fieldData, function (data) {
            if (data.NoticeType == 0) {
                $('#lblNoticeType').text("全部");
            } else {
                $('#lblNoticeType').text('未知');
            }
            if (data.Status == 1) {
                $('#lblStatus').text("屏蔽");
            } else {
                $('#lblStatus').text("发布");
            }
            if (data.IsTip == 1) {
                $('#lblIsTip').text("提示");
            } else {
                $('#lblIsTip').text("不提示");
            }
            $('#lblPublishDate').text(app.getTDate2(data.PublishDate));
            editor.html(HtmlUtil.htmlDecode(data.NoticeDescription));

            form.render();
        }, function (err) {
            layer.msg('请求失败');
        });
    }
});

var editor;
//初始化KindEditor
function setKindEditor() {
    editor = KindEditor.create('#txtNoticeDescription', {
        cssPath: '/resources/kindeditor/plugins/code/prettify.css',
        uploadJson: '/resources/kindeditor/asp.net/upload_json.ashx',
        fileManagerJson: '/resources/kindeditor/asp.net/file_manager_json.ashx',
        allowFileManager: true
    });
    editor.readonly(true);//禁用编辑器
}
